
package org.spring.config.client;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 
 * ClassName: EurekaConfigClientApp <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2019年10月10日 上午11:40:47 <br/>
 *
 * @author dengqian
 * @version
 * @since JDK 1.8
 */
//@EnableTurbine
//@EnableHystrixDashboard
@RestController
@EnableDiscoveryClient//(autoRegister=false)
// @RefreshScopehttps://github.com/georgezeng/geo-web-dynamic-test/tree/master/src/main/scala/com/geo
@SpringBootApplication
@ServletComponentScan
public class EurekaConfigClientApplication extends SpringBootServletInitializer {
//    ConfigServiceBootstrapConfiguration
    
    // DiscoveryClientConfigServiceBootstrapConfiguration
//    applicationConfigurationProperties
//    EurekaDiscoveryClientConfigServiceBootstrapConfiguration
//    MutablePropertySources
//    BootstrapConfiguration
//    PropertySourcesPropertyResolver
    private static final Logger LOGGER = LoggerFactory.getLogger(EurekaConfigClientApplication.class);
    
    @Resource
    private  ApplicationEventPublisher eventPublisher;
    
    @Resource
    private Environment environment;
    
    @Resource
    private ConfigurableApplicationContext context;
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(EurekaConfigClientApplication.class);
    }

    @GetMapping("/gp")
    public String getProps() {
        // EurekaClientAutoConfiguration
        // ServiceRegistry
        // EurekaRegistration
        // EurekaAutoServiceRegistration
        // DiscoveryClientConfigServiceBootstrapConfiguration
        // ServerProperties
        return environment.getProperty("zuul.debug.request");
    }


  
    public static void main(String[] args) {
        ConfigurableApplicationContext in =  SpringApplication.run(EurekaConfigClientApplication.class, args);

//        SpringBootServletInitializer 

    }
    
  
}
